package edu.sjb.map.prizes;

import edu.sjb.Drawable;
import edu.sjb.constants.ImageConstants;
import edu.sjb.constants.ScoreConstants;
import edu.sjb.threads.SoundThread;

public class Star extends PowerUp {
	public Star() {
		super();
	}

	@Override
	public void grab() {

		if (game().mario().underStarEffect()) {
			game().changeScore(ScoreConstants.STAR_ALREADY_HAVE);
		}
		else {
			game().changeScore(ScoreConstants.STAR);

		}
		game().mario().setPowerUp(this);
		game().mario().action2();
	}

	@Override
	public void run() {
		SoundThread.stopBGMOverworld();
		SoundThread.startBGMStar();
		game().mario().setUnderStarEffect(true);
		try {
			Thread.sleep(15000);
		}
		catch (InterruptedException e) {
		}
		game().mario().setUnderStarEffect(false);
		SoundThread.stopBGMStar();
		SoundThread.startBGMOverworld();
	}

	protected Object clone() {
		Star star = new Star();
		Drawable img = new Drawable(ImageConstants.STAR, true);
		star.setImage(img);
		return star;
	}

}
